function fig = PlotWorkingPoint(obj, wp)
    if nargin == 1
        wp = obj.SystemInfo.WorkingPoint;
    end
    fig = figure('Name', sprintf('WorkingPoint: [%s]', datestr(wp.timestamp)), 'WindowStyle', 'Docked');
    ax1 = subplot(3, 2, 1, 'Parent', fig);
    plotRawPhase(ax1, wp.signal.rawPhaseX, wp.fitting.rawPhaseX, 'PhaseX');
    ax2 = subplot(3, 2, 2, 'Parent', fig);
    plotRawPhase(ax2, wp.signal.rawPhaseY, wp.fitting.rawPhaseY, 'PhaseY');
    ax3 = subplot(3, 2, 3, 'Parent', fig);
    plotFinePhase(ax3, wp.signal.finePhaseX, wp.fitting.finePhaseX, 'PhaseX');
    ax4 = subplot(3, 2, 4, 'Parent', fig);
    plotFinePhase(ax4, wp.signal.finePhaseY, wp.fitting.finePhaseY, 'PhaseY');
    ax5 = subplot(3, 2, 5, 'Parent', fig);
    plotSlope(ax5, wp.signal.biasX, wp.fitting.biasX, 'BiasX');
    ax6 = subplot(3, 2, 6, 'Parent', fig);
    plotSlope(ax6, wp.signal.biasY, wp.fitting.biasY, 'BiasY');
end

function plotRawPhase(axes_handle, swprResult, fitting, name)
    data = swprResult.getNodeData(1); 
    phaseList = data.x;
    fitresult = fitting.result;
    phase0 = fitting.phase0;

    range = minmax(phaseList(:)'); xList = linspace(range(1), range(2), 181);
    plot(axes_handle, data.x, data.y, 'b.', xList, fitresult(xList), 'r-');
    legend(axes_handle, 'data', 'fitting', 'Location', 'best' );
    xlim(axes_handle, range);
    xlabel(axes_handle, [name ' (degree)']);
    ylabel(axes_handle, 'Demod Signal (V)');
    title(axes_handle, sprintf('\\phi_0 = %5.3f ^{\\circ}', phase0));
    grid on
end

function plotFinePhase(axes_handle, swprResult, fitting, name)
    data = swprResult.getNodeData(1); 
    fitresult = fitting.result;
    phase0 = fitting.phase0;
    residual = fitting.residual;
    
    xList = linspace(min(data.x), max(data.x), 101);
    switch fitting.model
        case 'poly2'
            plot(axes_handle, data.x, data.y, 'b.', xList, sqrt(fitresult(xList)), 'r-');
        case 'abs'
            plot(axes_handle, data.x, data.y, 'b.', xList, fitresult(xList), 'r-');
    end
    legend(axes_handle, 'Sweeper Data', 'Fitting', 'Location', 'NorthEast' );
    xlim(axes_handle, minmax(data.x(:)'));
    xlabel(axes_handle, [name ' (degree)']);
    ylabel(axes_handle, 'Demod Signal (V)');
    title(axes_handle, sprintf('\\phi_0 = %5.3f ^{\\circ} a_0 = %3.2e V', phase0, residual));
    grid on
end
function plotSlope(axes_handle, swprResult, fitting, name)
    data = swprResult.getNodeData(1);
    data_crs = swprResult.getNodeData(2);
    fitresult = fitting.result;
    slope = fitting.slope;
    zeropoint = fitting.zeropoint;

    plot(axes_handle, data.x, data.y, 'b.', data.x, fitresult(data.x), 'r-', data_crs.x, data_crs.y, 'k.-');
    legend(axes_handle, 'data', 'fitting', 'crs sig.', 'Location', 'best' );
    xlim(axes_handle, minmax(data.x(:)'));
    xlabel (axes_handle, [name ' Volt(V)']);
    ylabel (axes_handle, 'Demod signal(V)');
    grid on;
    title(axes_handle, sprintf('V_0=%4.3f V, k=%4.3f',zeropoint, slope));
end